#ifndef ACO_TOOL_H
#define ACO_TOOL_H

#include "define.h"

class tool {
public:
    static inline pair_int numToPair(int size, int num){
        pair_int t;
        t.second = num / size;
        t.first = num % size;

        return t;
    }

    static inline int pairToNum(int size, pair_int pai){
        int t = 0;
        t += pai.second * size;
        t += pai.first;

        return t;
    }

    static inline double distance(pair_int p1, pair_int p2) {
        return pow(pow(p1.first - p2.first, 2) + pow(p1.second - p2.second, 2), 0.5);
    }

    static inline int findMin(std::vector<double> array) {
        double min = INT32_MAX, res = 0, k = array.size();
        for(int i=0; i<k; ++i) {
            if(array[i] < min){
                min = array[i];
                res = i;
            }
        }
        return res;
    }
};

#endif //ACO_TOOL_H